home *** CD-ROM | disk | FTP | other *** search
/ Maclife 157 / MACLIFE157-2001-09.ISO.7z / MACLIFE157-2001-09.ISO / Linux / MacOS Tools / Other / BootX 1.1.3 (for Old Mac OS) / Sources / src / EnterPPCSupervisor.c < prev    next >
C/C++ Source or Header  |  2001-07-23  |  8KB  |  144 lines

  1. #include <CodeFragments.h>
  2. #include <MixedMode.h>
  3. #include <OSUtils.h>
  4. #include <Processes.h>
  5. #include <Traps.h>
  6.  
  7. #include "EnterPPCSupervisor.h"
  8.  
  9. // Implementation
  10. asm void EnterPPCSupervisor(PPCRegisterList* regList)
  11. {
  12.     // Load the address of the register list into a3
  13.     move.l    0x0004(sp),a3;
  14.     
  15.     // Disable 68K interrupts
  16.     ori.w    #0x0700,sr;
  17.     
  18.     // Mess with the stack!
  19.     move.l    sp,d0;
  20.     andi.l    #0xFFFFFC00,d0;
  21.     move.l    d0,sp;
  22.     move.l    #0x00BF,d0;
  23. @loop:
  24.     clr.l        -(sp);
  25.     dbra        d0,@loop;
  26.     
  27.     // Set up the program counter
  28.     move.l    struct(PPCRegisterList.PC)(a3),0x00FC(sp);                // PC
  29.     
  30.     // Set up the general-purpose registers
  31.     move.l    struct(PPCRegisterList.GPR)+0*4(a3),0x0100+0*8+4(sp);    // R0
  32.     move.l    struct(PPCRegisterList.GPR)+1*4(a3),0x0100+1*8+4(sp);    // R1
  33.     move.l    struct(PPCRegisterList.GPR)+2*4(a3),0x0100+2*8+4(sp);    // R2
  34.     move.l    struct(PPCRegisterList.GPR)+3*4(a3),0x0100+3*8+4(sp);    // R3
  35.     move.l    struct(PPCRegisterList.GPR)+4*4(a3),0x0100+4*8+4(sp);    // R4
  36.     move.l    struct(PPCRegisterList.GPR)+5*4(a3),0x0100+5*8+4(sp);    // R5
  37.     move.l    struct(PPCRegisterList.GPR)+6*4(a3),0x0100+6*8+4(sp);    // R6
  38.     move.l    struct(PPCRegisterList.GPR)+7*4(a3),0x0100+7*8+4(sp);    // R7
  39.     move.l    struct(PPCRegisterList.GPR)+8*4(a3),0x0100+8*8+4(sp);    // R8
  40.     move.l    struct(PPCRegisterList.GPR)+9*4(a3),0x0100+9*8+4(sp);    // R9
  41.     move.l    struct(PPCRegisterList.GPR)+10*4(a3),0x0100+10*8+4(sp);    // R10
  42.     move.l    struct(PPCRegisterList.GPR)+11*4(a3),0x0100+11*8+4(sp);    // R11
  43.     move.l    struct(PPCRegisterList.GPR)+12*4(a3),0x0100+12*8+4(sp);    // R12
  44.     move.l    struct(PPCRegisterList.GPR)+13*4(a3),0x0100+13*8+4(sp);    // R13
  45.     move.l    struct(PPCRegisterList.GPR)+14*4(a3),0x0100+14*8+4(sp);    // R14
  46.     move.l    struct(PPCRegisterList.GPR)+15*4(a3),0x0100+15*8+4(sp);    // R15
  47.     move.l    struct(PPCRegisterList.GPR)+16*4(a3),0x0100+16*8+4(sp);    // R16
  48.     move.l    struct(PPCRegisterList.GPR)+17*4(a3),0x0100+17*8+4(sp);    // R17
  49.     move.l    struct(PPCRegisterList.GPR)+18*4(a3),0x0100+18*8+4(sp);    // R18
  50.     move.l    struct(PPCRegisterList.GPR)+19*4(a3),0x0100+19*8+4(sp);    // R19
  51.     move.l    struct(PPCRegisterList.GPR)+20*4(a3),0x0100+20*8+4(sp);    // R20
  52.     move.l    struct(PPCRegisterList.GPR)+21*4(a3),0x0100+21*8+4(sp);    // R21
  53.     move.l    struct(PPCRegisterList.GPR)+22*4(a3),0x0100+22*8+4(sp);    // R22
  54.     move.l    struct(PPCRegisterList.GPR)+23*4(a3),0x0100+23*8+4(sp);    // R23
  55.     move.l    struct(PPCRegisterList.GPR)+24*4(a3),0x0100+24*8+4(sp);    // R24
  56.     move.l    struct(PPCRegisterList.GPR)+25*4(a3),0x0100+25*8+4(sp);    // R25
  57.     move.l    struct(PPCRegisterList.GPR)+26*4(a3),0x0100+26*8+4(sp);    // R26
  58.     move.l    struct(PPCRegisterList.GPR)+27*4(a3),0x0100+27*8+4(sp);    // R27
  59.     move.l    struct(PPCRegisterList.GPR)+28*4(a3),0x0100+28*8+4(sp);    // R28
  60.     move.l    struct(PPCRegisterList.GPR)+29*4(a3),0x0100+29*8+4(sp);    // R29
  61.     move.l    struct(PPCRegisterList.GPR)+30*4(a3),0x0100+30*8+4(sp);    // R30
  62.     move.l    struct(PPCRegisterList.GPR)+31*4(a3),0x0100+31*8+4(sp);    // R31
  63.     
  64.     // Set up the floating-point registers
  65.     move.l    struct(PPCRegisterList.FPR)+0*8+0(a3),0x0200+0*8+0(sp);    // FPR0;
  66.     move.l    struct(PPCRegisterList.FPR)+0*8+4(a3),0x0200+0*8+4(sp);
  67.     move.l    struct(PPCRegisterList.FPR)+1*8+0(a3),0x0200+1*8+0(sp);    // FPR1;
  68.     move.l    struct(PPCRegisterList.FPR)+1*8+4(a3),0x0200+1*8+4(sp);
  69.     move.l    struct(PPCRegisterList.FPR)+2*8+0(a3),0x0200+2*8+0(sp);    // FPR2;
  70.     move.l    struct(PPCRegisterList.FPR)+2*8+4(a3),0x0200+2*8+4(sp);
  71.     move.l    struct(PPCRegisterList.FPR)+3*8+0(a3),0x0200+3*8+0(sp);    // FPR3;
  72.     move.l    struct(PPCRegisterList.FPR)+3*8+4(a3),0x0200+3*8+4(sp);
  73.     move.l    struct(PPCRegisterList.FPR)+4*8+0(a3),0x0200+4*8+0(sp);    // FPR4;
  74.     move.l    struct(PPCRegisterList.FPR)+4*8+4(a3),0x0200+4*8+4(sp);
  75.     move.l    struct(PPCRegisterList.FPR)+5*8+0(a3),0x0200+5*8+0(sp);    // FPR5;
  76.     move.l    struct(PPCRegisterList.FPR)+5*8+4(a3),0x0200+5*8+4(sp);
  77.     move.l    struct(PPCRegisterList.FPR)+6*8+0(a3),0x0200+6*8+0(sp);    // FPR6;
  78.     move.l    struct(PPCRegisterList.FPR)+6*8+4(a3),0x0200+6*8+4(sp);
  79.     move.l    struct(PPCRegisterList.FPR)+7*8+0(a3),0x0200+7*8+0(sp);    // FPR7;
  80.     move.l    struct(PPCRegisterList.FPR)+7*8+4(a3),0x0200+7*8+4(sp);
  81.     move.l    struct(PPCRegisterList.FPR)+8*8+0(a3),0x0200+8*8+0(sp);    // FPR8;
  82.     move.l    struct(PPCRegisterList.FPR)+8*8+4(a3),0x0200+8*8+4(sp);
  83.     move.l    struct(PPCRegisterList.FPR)+9*8+0(a3),0x0200+9*8+0(sp);    // FPR9;
  84.     move.l    struct(PPCRegisterList.FPR)+9*8+4(a3),0x0200+9*8+4(sp);
  85.     move.l    struct(PPCRegisterList.FPR)+10*8+0(a3),0x0200+10*8+0(sp);    // FPR10;
  86.     move.l    struct(PPCRegisterList.FPR)+10*8+4(a3),0x0200+10*8+4(sp);
  87.     move.l    struct(PPCRegisterList.FPR)+11*8+0(a3),0x0200+11*8+0(sp);    // FPR11;
  88.     move.l    struct(PPCRegisterList.FPR)+11*8+4(a3),0x0200+11*8+4(sp);
  89.     move.l    struct(PPCRegisterList.FPR)+12*8+0(a3),0x0200+12*8+0(sp);    // FPR12;
  90.     move.l    struct(PPCRegisterList.FPR)+12*8+4(a3),0x0200+12*8+4(sp);
  91.     move.l    struct(PPCRegisterList.FPR)+13*8+0(a3),0x0200+13*8+0(sp);    // FPR13;
  92.     move.l    struct(PPCRegisterList.FPR)+13*8+4(a3),0x0200+13*8+4(sp);
  93.     move.l    struct(PPCRegisterList.FPR)+14*8+0(a3),0x0200+14*8+0(sp);    // FPR14;
  94.     move.l    struct(PPCRegisterList.FPR)+14*8+4(a3),0x0200+14*8+4(sp);
  95.     move.l    struct(PPCRegisterList.FPR)+15*8+0(a3),0x0200+15*8+0(sp);    // FPR15;
  96.     move.l    struct(PPCRegisterList.FPR)+15*8+4(a3),0x0200+15*8+4(sp);
  97.     move.l    struct(PPCRegisterList.FPR)+16*8+0(a3),0x0200+16*8+0(sp);    // FPR16;
  98.     move.l    struct(PPCRegisterList.FPR)+16*8+4(a3),0x0200+16*8+4(sp);
  99.     move.l    struct(PPCRegisterList.FPR)+17*8+0(a3),0x0200+17*8+0(sp);    // FPR17;
  100.     move.l    struct(PPCRegisterList.FPR)+17*8+4(a3),0x0200+17*8+4(sp);
  101.     move.l    struct(PPCRegisterList.FPR)+18*8+0(a3),0x0200+18*8+0(sp);    // FPR18;
  102.     move.l    struct(PPCRegisterList.FPR)+18*8+4(a3),0x0200+18*8+4(sp);
  103.     move.l    struct(PPCRegisterList.FPR)+19*8+0(a3),0x0200+19*8+0(sp);    // FPR19;
  104.     move.l    struct(PPCRegisterList.FPR)+19*8+4(a3),0x0200+19*8+4(sp);
  105.     move.l    struct(PPCRegisterList.FPR)+20*8+0(a3),0x0200+20*8+0(sp);    // FPR20;
  106.     move.l    struct(PPCRegisterList.FPR)+20*8+4(a3),0x0200+20*8+4(sp);
  107.     move.l    struct(PPCRegisterList.FPR)+21*8+0(a3),0x0200+21*8+0(sp);    // FPR21;
  108.     move.l    struct(PPCRegisterList.FPR)+21*8+4(a3),0x0200+21*8+4(sp);
  109.     move.l    struct(PPCRegisterList.FPR)+22*8+0(a3),0x0200+22*8+0(sp);    // FPR22;
  110.     move.l    struct(PPCRegisterList.FPR)+22*8+4(a3),0x0200+22*8+4(sp);
  111.     move.l    struct(PPCRegisterList.FPR)+23*8+0(a3),0x0200+23*8+0(sp);    // FPR23;
  112.     move.l    struct(PPCRegisterList.FPR)+23*8+4(a3),0x0200+23*8+4(sp);
  113.     move.l    struct(PPCRegisterList.FPR)+24*8+0(a3),0x0200+24*8+0(sp);    // FPR24;
  114.     move.l    struct(PPCRegisterList.FPR)+24*8+4(a3),0x0200+24*8+4(sp);
  115.     move.l    struct(PPCRegisterList.FPR)+25*8+0(a3),0x0200+25*8+0(sp);    // FPR25;
  116.     move.l    struct(PPCRegisterList.FPR)+25*8+4(a3),0x0200+25*8+4(sp);
  117.     move.l    struct(PPCRegisterList.FPR)+26*8+0(a3),0x0200+26*8+0(sp);    // FPR26;
  118.     move.l    struct(PPCRegisterList.FPR)+26*8+4(a3),0x0200+26*8+4(sp);
  119.     move.l    struct(PPCRegisterList.FPR)+27*8+0(a3),0x0200+27*8+0(sp);    // FPR27;
  120.     move.l    struct(PPCRegisterList.FPR)+27*8+4(a3),0x0200+27*8+4(sp);
  121.     move.l    struct(PPCRegisterList.FPR)+28*8+0(a3),0x0200+28*8+0(sp);    // FPR28;
  122.     move.l    struct(PPCRegisterList.FPR)+28*8+4(a3),0x0200+28*8+4(sp);
  123.     move.l    struct(PPCRegisterList.FPR)+29*8+0(a3),0x0200+29*8+0(sp);    // FPR29;
  124.     move.l    struct(PPCRegisterList.FPR)+29*8+4(a3),0x0200+29*8+4(sp);
  125.     move.l    struct(PPCRegisterList.FPR)+30*8+0(a3),0x0200+30*8+0(sp);    // FPR30;
  126.     move.l    struct(PPCRegisterList.FPR)+30*8+4(a3),0x0200+30*8+4(sp);
  127.     move.l    struct(PPCRegisterList.FPR)+31*8+0(a3),0x0200+31*8+0(sp);    // FPR31;
  128.     move.l    struct(PPCRegisterList.FPR)+31*8+4(a3),0x0200+31*8+4(sp);
  129.     
  130.     // This causes the 68K emulator to put us in priviledged mode and execute our routine.
  131.     move.l    #'Gary',a0;
  132.     move.l    #0x05051956,a1;
  133.     move.l    #0x0000C000,d0;
  134.     moveq    #0,d2;
  135.     reset;
  136.     
  137.     move.l    sp,-(sp);
  138. wait:
  139.     dc.w    0xFE03;
  140.     beq        wait;
  141.     
  142.     rts;
  143. }
  144.